package com.medical.service.impl;

import com.medical.mapper.MyRepairMapper;
import com.medical.pojo.MyRepair;
import com.medical.service.MyRepairService;
import com.medical.vo.Rmed;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class MyRepairServiceImpl implements MyRepairService {

    @Autowired
    private MyRepairMapper myRepairMapper;

    @Override
    public List<MyRepair> findAll() {
        return myRepairMapper.findAll();
    }

    @Override
    public MyRepair findById(Integer id) {
        List<MyRepair> list = myRepairMapper.findAll();
        Optional<MyRepair> first = list.stream().filter(myRepair -> myRepair.getId().equals(id)).findFirst();
        return first.get();
    }

    @Override
    public Rmed updateRepair(MyRepair myRepair) {
        myRepairMapper.updateRepair(myRepair);
        return Rmed.suceess();
    }

    @Override
    public Rmed updateReject(MyRepair myRepair) {
        myRepairMapper.updateReject(myRepair);
        return Rmed.suceess();
    }
}
